package com.blog.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blog.model.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blog.model.vo.ArticleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhengxin
 * @since 2019-03-29
 */
@Repository
public interface ArticleMapper extends BaseMapper<Article> {

    @Select(" select  a.id , a.title ,a.admin_id , admin.username as adminName , a.channel , a.labels , a.content , a.status, a.view_count , a.up_count  ,a.down_count , a.create_date , a.update_time ,a.images " +
            " from article a left join admin admin  on a.admin_id = admin.id ")
    List<ArticleVO> pageFrontArticleVO(Page<ArticleVO >articleVOPage , QueryWrapper<ArticleVO> queryWrapper);


    @Select(" select  a.id , a.title ,a.admin_id , admin.username as adminName , a.channel , a.labels , a.content , a.status, a.view_count , a.up_count  ,a.down_count , a.create_date , a.update_time ,a.images " +
            " from article a left join admin admin  on a.admin_id = admin.id where a.id = #{id} ")
    ArticleVO getOne(@Param("id") Long id);

}
